<?php
// +----------------------------------------------------------------------
// | INPHP
// | Copyright (c) 2023 https://inphp.cc All rights reserved.
// | Author: 幺月儿(https://gitee.com/lulanyin) Email: inphp@qq.com
// | 该文件的开源协议以所在项目的LICENSE文件为准，请遵守开源协议要求
// +----------------------------------------------------------------------
// | 获取文章下一篇
// +----------------------------------------------------------------------
namespace app\cms\tags;

use Inphp\Core\Context;

class next extends prevNext
{
    public static function process(array $params): array
    {
        $id = $params["id"] ?? 0;
        $id = is_numeric($id) && $id > 0 ? ceil($id) : 0;
        if ($id <= 0) {
            return [];
        }
        $categoryId = $params["categoryId"] ?? 0;
        $categoryId = is_numeric($categoryId) && $categoryId > 0 ? ceil($categoryId) : 0;
        //站点识别
        $site = Context::get("CMS_SITE");
        $siteId = $site ? $site["id"] : 0;
        $next = self::get($id, $categoryId, $siteId, true);
        $data = !empty($prev) ? [$next] : [];
        return isset($params["assign"]) ? $next : $data;
    }
}